#include "StdAfx.h"
#include "ToolbarTitlePanelUI.h"

#define IDB_BITMAP_LOGO 134
const int IDB_BITMAP_LOGO_WIDTH = 110;
const int IDB_BITMAP_LOGO_HEIGHT = 30;

CToolbarTitlePanelUI::CToolbarTitlePanelUI(void): m_iPadding(6),m_hBitmapLogo(NULL)
{
	LoadSkin();
}

CToolbarTitlePanelUI::~CToolbarTitlePanelUI(void)
{
	if(m_hBitmapLogo != NULL)
		DeleteObject(m_hBitmapLogo);
}

LPCTSTR CToolbarTitlePanelUI::GetClass() const
{
	return _T("ToolbarTitlePanelUI");
}

SIZE CToolbarTitlePanelUI::EstimateSize(SIZE szAvailable)
{
	
	SIZE sz = { 0 };
	RECT rcText = { 0, 0, szAvailable.cx, szAvailable.cy };
	::InflateRect(&rcText, -m_iPadding, -m_iPadding);
	int nLinks = 0;
	CBlueRenderEngineUI::DoPaintPrettyText(m_pManager->GetPaintDC(), m_pManager, rcText, m_sText, UICOLOR_EDIT_TEXT_NORMAL, UICOLOR__INVALID, NULL, nLinks, DT_WORDBREAK | DT_CALCRECT);
	//CBlueRenderEngineUI::DoPaintPrettyText(m_pManager->GetPaintDC(), m_pManager, rcText, m_sText, UICOLOR_EDIT_TEXT_NORMAL, UICOLOR__FIRST, NULL, nLinks, DT_WORDBREAK | DT_CALCRECT);
	sz.cy = (rcText.bottom - rcText.top) + (m_iPadding * 2);
	return sz;
}

void CToolbarTitlePanelUI::DoPaint(HDC hDC, const RECT& rcPaint)
{
	CBlueRenderEngineUI::DoPaintPanel(hDC, m_pManager, m_rcItem);
	RECT rcText = m_rcItem;
	::InflateRect(&rcText, -m_iPadding, -m_iPadding);
	int nLinks = 0;
	//CBlueRenderEngineUI::DoPaintPrettyText(hDC, m_pManager, rcText, m_sText, UICOLOR_TITLE_TEXT, UICOLOR__INVALID, NULL, nLinks, DT_WORDBREAK | DT_NOPREFIX);
	CBlueRenderEngineUI::DoPaintPrettyText(hDC, m_pManager, rcText, m_sText, UICOLOR_EDIT_TEXT_NORMAL, UICOLOR__INVALID, NULL, nLinks, DT_WORDBREAK | DT_NOPREFIX);
	RECT rcLogo = rcText;
	rcLogo.left = rcLogo.right - IDB_BITMAP_LOGO_WIDTH;
	rcLogo.top = (rcText.bottom - rcText.top - IDB_BITMAP_LOGO_HEIGHT)/2;
	rcLogo.bottom = rcLogo.top + IDB_BITMAP_LOGO_HEIGHT;
	//CBlueRenderEngineUI::DoPaintBitmap(hDC,m_pManager,m_hBitmapLogo,rcLogo);
}

void CToolbarTitlePanelUI::LoadSkin()
{
	m_hBitmapLogo = (HBITMAP) ::LoadImage(m_pManager->GetResourceInstance(), MAKEINTRESOURCE(IDB_BITMAP_LOGO), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
	ASSERT(m_hBitmapLogo!=NULL);
}
